package cn.tedu.csmall.product.Controller;

import cn.tedu.csmall.product.service.ICategoryService;
import cn.tedu.csmall.product.web.JsonResult;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.hibernate.validator.constraints.Range;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import static jdk.nashorn.internal.runtime.regexp.joni.Config.log;

/**
 * @author liyang
 * @version 1.0
 * @package cn.tedu.csmall.product.Controller
 * @file BrandController.java
 * @description
 * @time 2024/9/4 下午11:33
 */
@Slf4j
@RestController
@RequestMapping("/album")
@Api(tags = "品牌管理模块")
public class BrandController {

    @Autowired
    private ICategoryService categoryService;
    // http://localhost:9080/categories/9527/delete
    @PostMapping("/{id:[0-9]+}/delete")
    @ApiOperation("根据id删除类别")
    @ApiOperationSupport(order = 200)
    @ApiImplicitParam(name = "id", value = "类别ID", required = true, example = "9527", dataType = "long")
    public JsonResult<Void> delete(@Range(min = 1, max = 1000000, message = "删除类别失败，类别ID非法！")
                                   @PathVariable Long id) {
        log.debug("开始处理【根据id删除类别】的请求，参数：{}", id);
        categoryService.delete(id);
        return JsonResult.ok();
    }
}
